/**
 * @Author: Nico
 */
import { openLayerId } from './openLayerId'
import { openPdaLayerId } from './openPdaLayerId'

//必须带done回调 执行完成调用
export default function pdaOpenLayer({ vm, module, action, callbackData, additionalData, done, _task, _index, eventName }) {
  console.log('测试openLayer', {
    vm,
    module,
    action,
    callbackData,
    additionalData,
    done,
    _task,
    _index,
  })

  const mode = process.env.VUE_APP_BuildProjectType === 'mobile' || vm.$store.state.diy.settings.mode === 'mobile'
  if (mode) {
    // 这里是array 但是是单选 就默认取0
    if (action.extension.layer.value.length > 0) {
      let layerId = action.extension.layer.value[0]
      openPdaLayerId(vm, layerId, done, eventName)
    } else {
      done(null, {})
    }
  } else {
    // 这里是array 但是是单选 就默认取0
    if (action.extension.layer.value.length > 0) {
      let layerId = action.extension.layer.value[0]
      openLayerId(vm, layerId, done, eventName)
    } else {
      done(null, {})
    }
  }
}
